package cn.ffcs.uec.outStaff.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import cn.ffcs.uec.common.vo.UecBdDefdoc;
import cn.ffcs.uec.organization.model.UecOrgDept;
import cn.ffcs.uec.organization.model.UecOrgOrgs;
import cn.ffcs.uec.outStaff.dao.UecOutStaffDao;
import cn.ffcs.uec.post.model.UecPost;
import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.model.UomEntity;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.StrUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * 外包人员工作记录
 *
 */
public class UecOutStaffWork extends UomEntity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6969345251188906091L;

	/**
	 * 外包人员主键标识
	 * 
	 * @return
	 */
	public Long getOutStaffWorkId() {
		return super.getId();
	}

	public void setOutStaffWorkId(Long outStaffWorkId) {
		super.setId(outStaffWorkId);
	}

	/**
	 * 账期
	 */
	@Getter
	@Setter
	private Long monthId;
	/**
	 * 主键
	 */
	@Getter
	@Setter
	private String pkPsnWork;
	/**
	 * 人员外键
	 */
	@Getter
	@Setter
	private Long outStaffId;
	/**
	 * 人员外键
	 */
	@Getter
	@Setter
	private String pkPsnMsg;
	/**
	 * 业务管理公司
	 */
	@Getter
	@Setter
	private String busiCorp;
	/**
	 * 业务管理部门
	 */
	@Getter
	@Setter
	private String busiDept;
	/**
	 * 基准岗位
	 */
	@Getter
	@Setter
	private String pkOmJob;
	/**
	 * 岗位名称
	 */
	@Getter
	@Setter
	private String jobName;
	/**
	 * 在本单位从事外包开始日期
	 */
	@Getter
	@Setter
	private String beginDate;
	/**
	 * 所属外包公司
	 */
	@Getter
	@Setter
	private String pkCorp;
	/**
	 * 所属外包公司
	 */
	@Getter
	@Setter
	private String unitname;
	/**
	 * 外包公司用工类别
	 */
	@Getter
	@Setter
	private String jobType;
	/**
	 * 退回外包公司日期
	 */
	@Getter
	@Setter
	private String endDate;
	/**
	 * 职业资格名称
	 */
	@Getter
	@Setter
	private String qualiName;
	/**
	 * 职业资格等级
	 */
	@Getter
	@Setter
	private String qualiLevel;
	/**
	 * 人员状态
	 */
	@Getter
	@Setter
	private Long psnStatus;
	/**
	 * 人员类型
	 */
	@Getter
	@Setter
	private Long psnType;
	/**
	 * 合同主键
	 */
	@Getter
	@Setter
	private String pkCt;

	/**
	 * 机构备注
	 */
	@Getter
	@Setter
	private String orgremark;
	/**
	 * 时间戳
	 */
	@Getter
	@Setter
	private String ts;
	/**
	 * 删除标志
	 */
	@Getter
	@Setter
	private Long dr;
	/**
	 * 是否小CEO
	 */
	@Getter
	@Setter
	private String isSCEO;
	/**
	 * 外包开始时间
	 */
	@Getter
	@Setter
	private String wbBeginDate;
	/**
	 * 外包结束时间
	 */
	@Getter
	@Setter
	private String wbEndDate;
	/**
	 * 数据来源<手工录入,系统同步>
	 */
	@Getter
	@Setter
	private String dataSources;

	public UecOutStaffWork() {
		super();
	}
	
	public static UecOutStaffWork newInstance() {
		return new UecOutStaffWork();
	}

	public UecOutStaffDao repository() {
		return (UecOutStaffDao) ApplicationContextUtil.getBean("uecOutStaffDao");
	}

	/**
	 * 获取业务管理公司--busiCorp
	 * 
	 * @return
	 */
	public String getBusiCorpName() {
		if (!StrUtil.isNullOrEmpty(this.getBusiCorp())) {
			String sql = " SELECT * FROM  UEC_ORG_ORGS T WHERE T.STATUS_CD = ? AND T.PK_ORG = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getBusiCorp());
			List<UecOrgOrgs> list = this.repository().jdbcFindList(sql, params, UecOrgOrgs.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	/**
	 * 获取业务管理部门--busiDept
	 * @return
	 */
	public String getBusiDeptName() {
		if (!StrUtil.isNullOrEmpty(this.getBusiDept())) {
			String sql = " SELECT * FROM  UEC_ORG_DEPT T WHERE T.STATUS_CD = ? AND T.PK_DEPT = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getBusiDept());
			List<UecOrgDept> list = this.repository().jdbcFindList(sql, params, UecOrgDept.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	
	/**
	 * 外包公司用工类别--jobType
	 * @return
	 */
	public String getJobTypeName() {
		if (!StrUtil.isNullOrEmpty(this.getJobType())) {
			String sql = " SELECT * FROM  UEC_BD_DEFDOC T WHERE T.PK_DEFDOC = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(this.getJobType());
			List<UecBdDefdoc> list = this.repository().jdbcFindList(sql, params, UecBdDefdoc.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getName();
			}
		}
		return "";
	}
	
	/**
	 * 获取基准岗位--pkOmJob
	 * @return
	 */
	public String getPkOmJobName() {
		if (!StrUtil.isNullOrEmpty(this.getPkOmJob())) {
			String sql = " SELECT * FROM  UEC_POST T WHERE T.STATUS_CD = ? AND T.PK_POST = ? ";
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			params.add(this.getPkOmJob());
			List<UecPost> list = this.repository().jdbcFindList(sql, params, UecPost.class);
			if (list != null && list.size() > 0) {
				return list.get(0).getPostname();
			}
		}
		return "";
	}
	

	public String getPsnStatusName() {
		if (null != this.getPsnStatus()) {
			if (0 == psnStatus) {
				return "在职";
			} else if (1 == psnStatus) {
				return "退出";
			}
		}
		return null;
	}

	public String getPsnTypeName() {
		if (null != this.getPsnType()) {
			if (0 == psnType) {
				return "新进";
			} else if (1 == psnType) {
				return "变更";
			} else if (3 == psnType) {
				return "退出";
			}
		}
		return null;
	}



}
